<?php
/**
 * 前台列表页控制器。
 *
 * @author    Fairyin <fairyin@126.com>
 * @copyright © 2016 www.imcn.vip
 * @version   v1.0
 */

namespace App\Http\Controllers;

use View;
use Config;
use App\Http\Model\Album;
use App\Http\Model\Type;
use App\Http\Model\Tag;

class ListController extends Shadow\ShadowController
{
    /**
     * 是否获取猜你喜欢模块内容。
     */
    const GET_LOVE = true;
    
    public function onGet()
    {
        //列表
        $a_lists = $this->getAllLists();
        shuffle($a_lists);
        if (count($a_lists) && Config::get('app.env') == 'production') {
            foreach ($a_lists as &$vv) {
                $vv['cover'] = $this->getBaseUrl($vv['cover'] . '-cover.jpg');
            }
        }
        $this->results['lists'] = $a_lists;
        //类型
        $o_types = Type::where('status', '=', 'enable')->get();
        $this->results['types'] = $o_types;
        $o_tags = Tag::where('status', '=', 'enable')->get();
        $this->results['tags'] = $o_tags;
        
        return View::make('list', $this->results);
    }
}
